//
//  AddressView.m
//  phmall
//
//  Created by admin on 2017/12/12.
//  Copyright © 2017年 admin. All rights reserved.
//

#import "AddressView.h"

@implementation AddressView

-(instancetype)init{
    if (self=[super init]) {
        self.backgroundColor=[UIColor whiteColor];
        self.addressImg=[[UIImageView alloc]init];
        self.addressImg.image=[UIImage imageNamed:@"收货地址-1"];
        [self addSubview:self.addressImg];
    
        
        self.name=[[UILabel alloc]init];
        self.name.text=@"收货人:啦啦啦";
        [self addSubview:self.name];
        self.name.font=[UIFont systemFontOfSize:15];
        self.name.hidden=YES;
        
        self.address=[[UILabel alloc]init];
//        self.address.text=@"收货地址:福建省 泉州市 石狮市 灵秀镇 世贸国际 华闽写字楼15楼 滚石网络有限公司 1503";
        [self addSubview:self.address];
        self.address.numberOfLines=2;
        self.address.textColor=[UIColor colorWithHexString:@"#adadad"];
        self.address.font=[UIFont systemFontOfSize:13];
        self.address.hidden=YES;
        
        self.phone=[[UILabel alloc]init];
        self.phone.text=@"联系电话:18658397382";
        [self addSubview:self.phone];
        self.phone.textColor=[UIColor colorWithHexString:@"#adadad"];
        self.phone.font=[UIFont systemFontOfSize:13];
        self.phone.hidden=YES;
        
        self.decorate=[[UIImageView alloc]init];
        self.decorate.image=[UIImage imageNamed:@"确认订单装饰线"];
        [self addSubview:self.decorate];
//        self.decorate.hidden=YES;
        
        self.noChoose=[[UILabel alloc]init];
        self.noChoose.text=Localized(@"选择地址>");
        [self addSubview:self.noChoose];
        self.noChoose.font=[UIFont systemFontOfSize:16];
        self.noChoose.hidden=NO;
    
    }
    return self;
}
-(void)layoutSubviews{
    [super layoutSubviews];
    CGSize superSize = self.frame.size;
    
    if (CGSizeEqualToSize(superSize, CGSizeZero)) {
        return;
    }
    [self.addressImg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.offset(0);
        make.left.offset(10);
        make.height.width.offset(20);
    }];
    
    [self.name mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(40);
        make.top.equalTo(self).offset(15);
    }];
    
    [self.address mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(40);
        make.width.offset(SCREEN_WIDTH-50);
        make.centerY.equalTo(self.addressImg);
    }];
    
    [self.phone mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(40);
//        make.width.offset(SCREEN_WIDTH-50);
        make.top.equalTo(self.address.mas_bottom).offset(6);
    }];
    
    [self.decorate mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.phone.mas_bottom).offset(15);
        make.left.right.offset(0);
        make.height.offset(4);
    }];
    
    [self.noChoose mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(40);
        make.width.offset(SCREEN_WIDTH-50);
        make.centerY.equalTo(self.addressImg);
    }];
}
-(void)setModel:(AddressModel *)model{
    _model=model;
    self.name.text=[NSString stringWithFormat:@"%@:%@",Localized(@"收货人"),model.consignee];
    self.address.text=[NSString stringWithFormat:@"%@:%@  %@  %@  %@",Localized(@"收货地址"),model.province,model.city,model.county,model.address];
    self.phone.text=[NSString stringWithFormat:@"联系电话:%@",model.mobile];
    self.noChoose.hidden=YES;
    
    self.name.hidden=NO;
    self.address.hidden=NO;
    self.phone.hidden=NO;
}
@end
